#coding=utf-8
import random
money=2000
commodity=[
 #     0      1
    ["老干妈",25],#0
    ["火锅底料",310],#1
    ["辣条",1.5],#2
    ["江小白",45],
    ["重庆小面",4],
    ["老干爹",55],
    ["佛跳墙",999],
    ["杨桃",10],
    ["丑橘",20]#8
]
print("消费满一千减一百")
car=[]

huafei=0
choujiang = random.randint(0, 2)
if choujiang == 0:
    print("恭喜抽中老干妈八折券")
    commodity[0][1] = commodity[0][1] * 0.8
elif choujiang == 1:
    print("恭喜抽中火锅底料一折券")
    commodity[1][1] = commodity[1][1] * 0.1
elif choujiang == 2:
    print("恭喜抽中买老干爹1折券")
    commodity[5][1] = commodity[5][1] *0.1
while True:

    for i in enumerate(commodity):#展示商品
        print(i)
    a=input("请输入商品编号")
    if a.isdigit():#判断是不是数字
        a=int(a)
        if a>=0 and a<=len(commodity)-1 :#9#判断输入的范围
            if money>=commodity[a][1]:
                car.append(commodity[a])
                huafei=huafei+commodity[a][1]
            else:#钱不够用
                print("钱不够，请结算输入q")
        else:#输入的超出范围
            print("没有改商品")

    elif a=="q" or a=="Q":#判断内容退出结算
        if huafei >= 1000:
            money = money + 100
            print("本次花费", huafei)
            print('花费满一千，自动返100到余额，余额为', money-huafei)
        elif huafei < 1000:
            print("本次花费", huafei)
            print("余额为", money - huafei)
        print("退出")
        break
